<template>
    <div class="powernjr">
        <span>
            注销素士账号是不可恢复的操作，您应自行备份素士账号相关信息和数据，操作之前，请你确认与素士账号相关的所有服务均已妥善处理。
        </span>
        <!-- <div class="btn">
            <el-button >删除账号</el-button>
         <el-button >个人中心</el-button>
        </div> -->
        <div class="btn">
          <LoginHeader>
        <el-button plain slot="i" @click="deleteuser">删除账号</el-button>
        <el-button plain slot="title">下载数据</el-button>
        </LoginHeader>
        </div>
    </div>
</template>
<script>
import LoginHeader from '@/components/njrcomponents/login_header.vue'
export default {
    components:{
        LoginHeader
    },
    methods:{
        deleteuser(){
            // console.log(this.$store.state.username);
             this.$confirm('此操作将永久删除该用户, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        //   this.$message({
        //     type: 'success',
        //     message: '删除成功!'
        //   });
        console.log(this.$store.state.username)
        this.$http.delete('/api/users/'+this.$store.state.username).then(({
            data,config
        })=>{
            if(data.code==200){
                   this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.$router.push('/login');
          window.sessionStorage.setItem("token",0)
            }else{
                this.$message({
            type: 'error',
            message: '删除失败!'
          });
            }
        })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
        }
    }
}
</script>
<style lang="less" scoped>
.powernjr{
    background-color: white;
    padding: 15px;
    .btn{
        margin-top: 60%;
        .el-button{
            border-radius: 35px;
            padding: 20px 50px;
            background-color: #5b20c6;
            color: white;
        }
    }
}

</style>
<style lang="less" >
.powernjr{
    .el-message-box__message>p{
    line-height: 0.52rem;
}
}
</style>